<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/5/10
 * Time: 下午8:58
 */

namespace App\Busi\Modules\Resource;


use App\Busi\Modules\BaseBusi;
use App\Busi\Traits\CategoryTrait;
use App\Http\Requests\CompanyCaseRo;
use App\Models\CompanyCase;

class CompanyCaseBusi extends BaseBusi
{
    use CategoryTrait;
    public function handle(CompanyCaseRo $ro){
        $company_id = $ro->id;

        $where = [
            ['company_id','=',$company_id]
        ];
        $fields = ['id','poster','company_name','category_id','service_desc','project_cycle','project_price','staff'];
        $data = CompanyCase::where($where)->select($fields)->get();

        foreach ($data as $item){
            $item['poster'] = config("admin.upload.host").$item['poster'];


            $item['category_name'] = $this->getFullCategoryNameByID($item['category_id']);

            unset($item['category_id']);

        }
        return $data;
    }
}